<!--
 * Copyright 2018 The Chromium Authors. All rights reserved.  Use of this
 * source code is governed by a BSD-style license that can be found in the
 * LICENSE file.
-->
<!DOCTYPE html>
<html>
<body>
  <video src="/media/bigbuck.webm"></video>
  <script>
    const video = document.getElementsByTagName('video')[0];

    function startPlaying() {
      video.play()
        .then(() => window.domAutomationController.send(true))
        .catch(() => window.domAutomationController.send(false));
    }

    function waitForPause() {
      if (video.paused) {
        window.domAutomationController.send(true);
        return;
      }

      video.addEventListener('pause', () => window.domAutomationController.send(true), { once: true });
    }

    function isPaused() {
      window.domAutomationController.send(video.paused);
    }
  </script>
</body>
</html>
